﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using MWTWorkUnitMgmtTool.BusinessEntities;

namespace MWTWorkUnitMgmtTool.ObjectFactories
{
    public class ObjectFactory
    {
        public ObjectFactory()
        {

        }

        public static ProductionWorkunit ProductionWorkunitFactory(IDataRecord record)
        {
            ProductionWorkunit productionWorkUnit = new ProductionWorkunit();
            productionWorkUnit.WUCode = record[0].ToString();
            productionWorkUnit.WUName = record[1].ToString();
            productionWorkUnit.ItemCode = record[2].ToString();
            productionWorkUnit.ItemName = record[3].ToString();
            productionWorkUnit.ParentItemCode = record[4].ToString();
            productionWorkUnit.ParentItemName = record[5].ToString();

            return productionWorkUnit;
        }

        public static SpecialWorkunit SpecialWorkunitFactory(IDataRecord record)
        {
            SpecialWorkunit specialWorkunit = new SpecialWorkunit();
            specialWorkunit.WUCode = record[0].ToString();
            specialWorkunit.WUName = record[1].ToString();
            specialWorkunit.WUType = record[2].ToString();
            specialWorkunit.Facility = record[3].ToString();

            return specialWorkunit; 
        }
        
        public static Mapping MappingFactory(IDataRecord record)
        {
            Mapping mapping = new Mapping();
            mapping.ID = Convert.ToInt32(record[0]); 
            mapping.WorkUnitCode = record[1].ToString();
            mapping.LocationCode = record[2].ToString();
            mapping.ItemCode = record[3].ToString();
            mapping.ItemName = record[4].ToString();

            return mapping;
        }

        public static WarehouseLocation WarehouseLocationFactory(IDataRecord record)
        {
            WarehouseLocation warehouseLocation = new WarehouseLocation();
            warehouseLocation.LocationCode = record[0].ToString();
            warehouseLocation.WhsCode = record[1].ToString();
            warehouseLocation.PhysicalLocation = record[2].ToString();
            warehouseLocation.AllowedTypes = record[3].ToString();
            warehouseLocation.Facility = record[4].ToString();
            warehouseLocation.IsLabelReprintLocation = record[5].ToString();

            return warehouseLocation;
        }

        public static Item ItemFactory(IDataRecord record)
        {
            Item item = new Item(); 
            item.ItemCode = record[0].ToString();
            item.ItemName = record[1].ToString();

            return item; 
        }

    }
}
